﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFollow : MonoBehaviour
{
    [SerializeField] private Transform player;
    private Vector3 pos;
    private Player playerScript;
    private float oneFollowTime;

    private void Awake()
    {
        playerScript = player.GetComponent<Player>();
    }


    private void LateUpdate()
    {
        if (playerScript.CheckCollisionByPlayerWithCircle() && oneFollowTime < 1.25f)
        {
            oneFollowTime += Time.deltaTime;
            pos = player.position - gameObject.transform.position;
            gameObject.transform.position += pos / 30;
            gameObject.transform.position = new Vector3(gameObject.transform.position.x, Mathf.Clamp(gameObject.transform.position.y, 0, float.MaxValue), -10);
        }
        else if(!playerScript.CheckCollisionByPlayerWithCircle()) oneFollowTime = .0f;

        
    }
}
